#ifndef RTC_H_
#define RTC_H_
#ifdef __cplusplus
extern "C" {
#endif
//#include <ctl_api.h>
#include <stdbool.h>
#include <assert.h>
#include <nxp/iolpc2378.h>                       /* LPC23xx/24xx definitions */
#include "irq.h"
//#include <targets/lpc2378.h>
//#include "LPC23xx.h"                        /* LPC23xx/24xx definitions */
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
/* Demo application includes. */
#define RTC_ALARMS_COUNT 6
static int TCUP=0;
static int TCUMN=0;
typedef struct {
  char month;
  char day;
  int  year;
  char hour;
  char minute;
  char second;
} datetime_t;

static int di=0;
typedef struct {
    DWORD RTC_Sec;     /* Second value - [0,59] */
    DWORD RTC_Min;     /* Minute value - [0,59] */
    DWORD RTC_Hour;    /* Hour value - [0,23] */
    DWORD RTC_Mday;    /* Day of the month value - [1,31] */
    DWORD RTC_Mon;     /* Month value - [1,12] */
    DWORD RTC_Year;    /* Year value - [0,4095] */
    DWORD RTC_Wday;    /* Day of week value - [0,6] */
    DWORD RTC_Yday;    /* Day of year value - [1,365] */
} RTCTime;

void rtc_alarm_set(unsigned int id, int period);
bool rtc_alarm_get(unsigned int id);
void SET_TSUP(int TSP);
void SET_TSUP_DI(int TSUP_DI);
void rtc_enable();

datetime_t rtc_get_time();
void rtc_set_time(datetime_t time);

extern __irq void RTCHandler( void ) ;
#ifdef __cplusplus
}
#endif

#endif /* RTC_H_ */
